< previous page page_58 next page >

Page 58
The following section of code gets the above information and then displays it to them; however, if there is not enough space for the file, the user will see an error message. You should place the following definitions at the beginning of the FileProcess routine that is in the application:
Dim Drive_TotalSpace As Long
Dim Drive_AvailableSpace As Long
Dim File_Size As Long
Dim FileInfo As Object
Dim sysInfo As New Scripting.FileSystemObject
The next section of code should be placed in the FileProcess routine immediately after the comment add FileSystemObject code here:
Drive_TotalSpace = SysInfo.Drives.Item(left(strTo_Filename,3)).TotalSize
Drive_AvailableSpace =
SysInfo.Drives.Item(left(strTo_Filename,3)).AvailableSpace _
Set FileInfo = SysInfo.GetFile(strFrom_Filename)
File_Size = FileInfo.Size
If File_Size > Drive_AvailableSpace Then
    MsgBox There is not enough space to process the file., vbCritical,App.Title
Else
    MsgBox Total Drive Space:  & cstr (Drive_TotalSpace) & vbCRLF & _
Available Drive Space:  & cstr (Drive_AvailableSpace) & vbCRLF & _
           Source File Size is:  & Cstr(File_Size), vbInformation, App.Title
End If
As you can see from this code, the File System Object makes it easy to access system information you might need for your application. Once you have added this code, try running the application to see the sizes of the drive you are using.
Colors..
The Color dialog box lets you select the colors that can be used for the foreground or background colors of your forms or controls. When you use the ShowColor method, the Color dialog box is displayed to users (see Figure 2.7), allowing them to choose a color.

 
< previous page page_58 next page >

If you like this book, buy it!